﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Petroleum.DB;
using Petroleum.DB.Model;
using System.Net;

namespace Petroleum.UC.Public
{
    public partial class GridTable_ColumnarSection : UserControl, HZH_Controls.Controls.IDataGridViewCustomCell
    {
        private Pressure m_object = null;
        public List<Image> images = new List<Image>();
        private Image GetImage(string url)
        {
            try
            {
                return global::Petroleum.Properties.Resources.logoV2;
                //return Image.FromStream();
            }
            catch
            {
                return new Bitmap(50, 50);
            }
        }
        public GridTable_ColumnarSection()
        {
            InitializeComponent();
        }

        public void SetBindSource(object obj)
        {
            if (obj is Pressure)
                m_object = (Pressure)obj;
        }

        private void GridTable_ColumnarSection_Load(object sender, EventArgs e)
        {

            //List<KeyValuePair<string, string>> lstCom = new List<KeyValuePair<string, string>>()
            //{
            //    new KeyValuePair<string, string>("1","Miocene - Quaternary"),
            //    new KeyValuePair<string, string>("2","Oligocene"),
            //    new KeyValuePair<string, string>("1","Paloe - Eocene"),
            //    new KeyValuePair<string, string>("3","Upper - cretac"),
            //    new KeyValuePair<string, string>("Mamastrichtian","Mamastrichtian"),
            //    new KeyValuePair<string, string>("Companian - Coniacian","Companian - Coniacian"),
            //    new KeyValuePair<string, string>("Turonian - Cenomanian","Turonian - Cenomanian"),

            //};
            //Age.Source = lstCom;

            images.Add(Properties.Resources.CS1);
            images.Add(Properties.Resources.CS2);
            images.Add(Properties.Resources.CS3);
            images.Add(Properties.Resources.CS4);
            images.Add(Properties.Resources.CS5);

            ColumnarSection.DrawMode = DrawMode.OwnerDrawFixed;
            ColumnarSection.DropDownStyle = ComboBoxStyle.DropDownList;
            ColumnarSection.DrawItem += comboBox1_DrawItem;

            ColumnarSection.Items.Add("1");
            ColumnarSection.Items.Add("2");
            ColumnarSection.Items.Add("3");
            ColumnarSection.Items.Add("4");
            ColumnarSection.Items.Add("5");
            ColumnarSection.SelectedIndex = 0;
            Controls.Add(ColumnarSection);
            //ucCombox1.Source = lstCom;
            //ucCombox1.SelectedIndex = 1;
        }

        private void ucCombox1_SelectedChangedEvent(object sender, EventArgs e)
        {
            if (m_object != null)
            {
                HZH_Controls.Forms.FrmTips.ShowTipsSuccess(this.FindForm(), "选中：" + ColumnarSection.SelectedValue);
            }
        }

        private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.Graphics.DrawImage(images[e.Index], 0, e.Bounds.Y, 16, 16);
            e.Graphics.DrawString(ColumnarSection.Items[e.Index].ToString(), new Font("宋体", 12), new SolidBrush(Color.Red), 20, e.Bounds.Y + 1);
        }

        private void ColumnarSection_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (m_object != null)
            {
                //Text = ColumnarSection.SelectedValue.ToString();
                m_object.ColumnarSection = ColumnarSection.Text;
                //HZH_Controls.Forms.FrmTips.ShowTipsSuccess(this.FindForm(), "选中：" + ColumnarSection.SelectedValue);
            }
        }
    }
}
